package com.ruoyi.slope.data.crack.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.slope.device.deviceInfo.domain.SlopeDeviceInfo;
import com.ruoyi.slope.device.deviceInfo.service.ISlopeDeviceInfoService;
import com.ruoyi.slope.device.deviceInfo.service.impl.SlopeDeviceInfoServiceImpl;
import com.ruoyi.slope.info.domain.SlopeInfo;
import com.ruoyi.slope.info.service.ISlopeInfoService;
import com.ruoyi.slope.monitorPoints.domain.SlopeMonitorpoints;
import com.ruoyi.slope.monitorPoints.service.impl.SlopeMonitorpointsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.slope.data.crack.mapper.SlopeCrackDataMapper;
import com.ruoyi.slope.data.crack.domain.SlopeCrackData;
import com.ruoyi.slope.data.crack.service.ISlopeCrackDataService;

/**
 * 边坡裂缝传感器监测数据Service业务层处理
 * 
 * @author psy
 * @date 2025-05-02
 */
@Service
public class SlopeCrackDataServiceImpl implements ISlopeCrackDataService 
{
    @Autowired
    private SlopeCrackDataMapper slopeCrackDataMapper;
    @Autowired
    private ISlopeDeviceInfoService slopeDeviceInfoService;
    @Autowired
    private ISlopeInfoService slopeInfoService;
    @Autowired
    private SlopeMonitorpointsServiceImpl slopeMonitorpointsServiceImpl;

    public void scanned(){
        slopeCrackDataMapper.scanned();
    }

    /**
     * 获取最新裂缝数据
     */
    @Override
    public SlopeCrackData getLatestCrackData(String deviceSn) {
        return slopeCrackDataMapper.selectLatestCrackData(deviceSn);
    }

    /**
     * 获取最新裂缝数据
     */
    @Override
    public SlopeCrackData getLatestCrackDataSet(String deviceSn) {
        return slopeCrackDataMapper.selectLatestCrackDataSet(deviceSn);
    }

    /**
     * 获取最新倾斜数据（结构物）
     */
    @Override
    public SlopeCrackData getLatestTiltData(String deviceSn) {
        return slopeCrackDataMapper.selectLatestTiltData(deviceSn);
    }

    /**
     * 获取最新加速度数据
     */
    @Override
    public SlopeCrackData getLatestAcceleration(String deviceSn) {
        return slopeCrackDataMapper.selectLatestAcceleration(deviceSn);
    }

    public List<SlopeCrackData> selectWarningDataList(SlopeCrackData slopeCrackData){
        return slopeCrackDataMapper.selectWarningDataList(slopeCrackData);
    }

    /**
     * 查询边坡裂缝传感器监测数据
     *
     * @param id 边坡裂缝传感器监测数据主键
     * @return 边坡裂缝传感器监测数据
     */
    @Override
    public SlopeCrackData selectSlopeCrackDataById(Long id)
    {
        return slopeCrackDataMapper.selectSlopeCrackDataById(id);
    }

    @Override
    public List<SlopeCrackData> selectSlopeCrackDataList(SlopeCrackData slopeCrackData) {
        List<SlopeCrackData> list = slopeCrackDataMapper.selectSlopeCrackDataList(slopeCrackData);
        return list;
    }





    public List<SlopeCrackData> selectSlopeQingXieDataList(SlopeCrackData slopeCrackData){
        List<SlopeCrackData> list = slopeCrackDataMapper.selectSlopeQingXieDataList(slopeCrackData);
        return list;
    }

    /**
     * 新增边坡裂缝传感器监测数据
     * 
     * @param slopeCrackData 边坡裂缝传感器监测数据
     * @return 结果
     */
    @Override
    public int insertSlopeCrackData(SlopeCrackData slopeCrackData)
    {
        slopeCrackData.setCreateTime(DateUtils.getNowDate());
        return slopeCrackDataMapper.insertSlopeCrackData(slopeCrackData);
    }

    /**
     * 修改边坡裂缝传感器监测数据
     * 
     * @param slopeCrackData 边坡裂缝传感器监测数据
     * @return 结果
     */
    @Override
    public int updateSlopeCrackData(SlopeCrackData slopeCrackData)
    {
        return slopeCrackDataMapper.updateSlopeCrackData(slopeCrackData);
    }

    /**
     * 批量删除边坡裂缝传感器监测数据
     * 
     * @param ids 需要删除的边坡裂缝传感器监测数据主键
     * @return 结果
     */
    @Override
    public int deleteSlopeCrackDataByIds(Long[] ids)
    {
        return slopeCrackDataMapper.deleteSlopeCrackDataByIds(ids);
    }

    /**
     * 删除边坡裂缝传感器监测数据信息
     * 
     * @param id 边坡裂缝传感器监测数据主键
     * @return 结果
     */
    @Override
    public int deleteSlopeCrackDataById(Long id)
    {
        return slopeCrackDataMapper.deleteSlopeCrackDataById(id);
    }
}
